import {Button, Input, PageHeader, Popconfirm } from "antd";
import {TipsText} from "../../components/TipsText";
import {CheckCircleOutlined, ConsoleSqlOutlined} from "@ant-design/icons";
import React from "react";
import {L7SQueueSqlPush} from "../../services/laike/logistics";
import {SuccessNotice,FailedNotice} from "../../components/Notice";


function L7sQueue() {
    const {TextArea} = Input

    const [sql,setSql] = React.useState("")
    const requestSql = ()=>{

        L7SQueueSqlPush({"sql":sql}).then(res=>{

            if(res.status !== 200){
                FailedNotice(res.status)
                return
            }

            if(res.data.code !== 200){
                FailedNotice(res.data.msg)
                return
            }

            SuccessNotice(res.data.msg)
        })
    }

    const getTextArea = e=>{
        setSql(e.target.value)
    }

    return (
        <>
            <PageHeader className="site-page-header" style={{paddingTop:0}}
                title="物流同步队列"
                subTitle="把查询的结果加入到队列中，等待队列周期执行同步"
            >
                <div>
                    必须参数：
                    <TipsText text=" shop_id,platform,order_id,logistics_no,logistics_company_code" icon={<CheckCircleOutlined />}/>
                </div>
            </PageHeader>

            <TextArea rows={15} allowClear={true} placeholder={"在此处输入SQL"} onChange={getTextArea}/>

            <div style={{textAlign:"right",marginTop:10}}>
                <Popconfirm
                    placement="left"
                    title="确定要执行该SQL？"
                    onConfirm={requestSql}
                    okText="True"
                    cancelText="False"
                >
                    <Button type={"primary"} size={"large"} icon={<ConsoleSqlOutlined />}>提交执行</Button>
                </Popconfirm>
            </div>
        </>
    )
}

export default L7sQueue

